package com.tledu.springboot01.controller;

import com.tledu.springboot01.model.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;

@Controller()
@RequestMapping("/index")
public class IndexController {

    @Autowired
    private HttpServletRequest request;

    @RequestMapping("index")
    public String index(Model model){
        model.addAttribute("name", "张三");
        model.addAttribute("content", "<h1>天亮教育</h1>");
        User user = new User();
        user.setId(10);
        user.setUsername("张三");
        user.setPassword("密码");
        user.setBirthday(new Date());
        model.addAttribute("user", user);
        model.addAttribute("user", user);
        Set<String> set = new HashSet<>();
        set.add("张三");
        set.add("李四");
        set.add("王五");
        model.addAttribute("2set", set);

        return "index";
    }


    @RequestMapping("detail")
    public String detail(Model model) {
        System.out.println(request.getParameter("name"));
        model.addAttribute("name", "李白");
        User user = new User();
        user.setId(10);
        user.setUsername("张三");
        model.addAttribute("user", user);


        return "detail";
    }


}
